package net.htjs.canaldemo.handler;

import net.htjs.canaldemo.entity.Fwxx;
import net.htjs.canaldemo.entity.User;
import net.htjs.canaldemo.repository.FwxxRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import top.javatool.canal.client.annotation.CanalTable;
import top.javatool.canal.client.handler.EntryHandler;

@Component
@CanalTable(value = "fcyth_jiananqu_fgj_fwxx")
public class FwxxHandler implements EntryHandler<Fwxx> {

    @Autowired
    private FwxxRepository fwxxRepository;

    @Override
    public void insert(Fwxx fwxx) {
        System.out.println("insert:" + fwxx);
        fwxxRepository.save(fwxx);
    }

    @Override
    public void update(Fwxx before, Fwxx after) {
        System.out.println("update:" + before + ":" + after);
        fwxxRepository.save(after);
    }

    @Override
    public void delete(Fwxx user) {
        System.out.println("delete:" + user);
        fwxxRepository.delete(user);
    }
}
